PAINT Statement ---------------------------------------------------------------------------- Action Fills a graphics area with the color or pattern specified. Syntax PAINT STEP ( x!, y!) , paint , bordercolor& , background$ Remarks The following list describes the parts of the PAINT statement. ----------------------------------------------------------------------------- Part Description ---------------------------------------------------------------------------- STEP Keyword indicating that coordinates are relative to the most recently plotted point. For example, if the last point plotted were (10,10), then the coordinates referred to by STEP (4,5) would be (4+10, 5+10) or (14,15). ( x!, y!) The coordinates where painting begins. The point must be inside or outside of a figure, not on the border itself. If this point is inside, the figure's interior is painted; if the point is on the outside, the background is painted. paint A numeric or string expression. If paint is a numeric expression, Part Description ---------------------------------------------------------------------------- paint is a numeric expression, then the number must be a valid color attribute. The corresponding color is used to paint the area. If you do not specify paint, the foreground color attribute is used. (See the COLOR, PALETTE, and SCREEN statements for discussions of valid colors, numbers, and attributes.) If the argument paint is a string expression, PAINT "tiles," a process that paints a pattern rather than a solid color. Tiling is similar to "line styling," which creates dashed lines rather than solid lines. Part Description ---------------------------------------------------------------------------- bordercolor& A numeric expression that identifies the color attribute to use to paint the border of the figure. When the border color is encountered, painting of the current line stops. If the border color is not specified, the paint argument is used. background$ A string value that gives the "background tile slice" to skip when checking for termination of the boundary. Painting is terminated when adjacent points display the paint color. Specifying a background tile slice allows you to paint over an already painted area. When you Part Description ---------------------------------------------------------------------------- already painted area. When you omit background$ the default is CHR$ (0). Painting is complete when a line is painted without changing the color of any pixel; in other words, when the entire line is equal to the paint color. The PAINT statement permits coordinates outside the screen or viewport. "Tiling" is the design of a PAINT pattern represented in string form. The tile string is eight bits wide and up to 64 bytes long. Each byte masks eight bits along the x axis when plotting points. The syntax for constructing the tile mask is A$ = CHR$( arg1)+ CHR$( arg2)+...+ CHR$( argn) PAINT ( x, y), A$ The arguments to CHR$ are numbers between 0 and 255, represented in binary form across the x axis of the tile. There can be up to 64 of these CHR$ elements; each generates an image not of the assigned character, but of the bit arrangement of the code for that character. For example, the decimal number 85 is binary 01010101; the graphic image line on a black-and-white screen generated by CHR$(85) is an eight-pixel line, with even-numbered points white and odd-numbered points black. That is, each bit equal to 1 turns the associated pixel on and each bit equal to 0 turns the associated bit off in a black-and-white system. The ASCII character CHR$(85), which is U, is not displayed in this case. When supplied, background$ defines the "background tile slice" to skip when checking for boundary termination. You cannot specify more than two consecutive bytes that match the tile string in the background tile slice. If you specify more than two consecutive bytes, BASIC generates an error message Illegal function call. Tiling also can be done to produce various patterns of different colors. See Chapter 5, "Graphics" in the Programmer's Guide for a complete description of how to do tiling. See Also CHR$, CIRCLE, DRAW, LINE, SCREEN Statement Example The following example uses PAINT to create a magenta fish with a cyan tail. CONST PI = 3.1415926536 CLS' Clear screen. SCREEN 1 CIRCLE (190, 100), 100, 1, , , .3' Outline fish body in cyan. CIRCLE (265, 92), 5, 1, , , .7' Outline fish eye in cyan. PAINT (190, 100), 2, 1' Fill in fish body with magenta. LINE (40, 120)-STEP (0, -40), 2 ' Outline tail in magenta. LINE -STEP (60, 20), 2 LINE -STEP (-60, 20), 2 PAINT (50, 100), 1, 2' Paint tail cyan. CIRCLE (250,100),30,0,PI*3-4,PI* 5-4,1.5' Draw gills in black. FOR Y = 90 TO 110 STEP 4 LINE (40, Y)-(52, Y), 0' Draw comb in tail. NEXT